package net.chrisrichardson.ormunit.hibernate;

import java.util.Set;


/**
 * Implements behavior common to both HibernateMappingTests (old version) and HibernateORMappingTests
 * @author cer
 *
 */
public abstract class AbstractORMappingTests extends HibernateORMTestCase {

	protected HibernateMappingChecker mappingChecker;
	protected MappedClassChecker classChecker;


	protected void onSetUp() throws Exception {
		super.onSetUp();
		this.mappingChecker = new HibernateMappingChecker(getConfiguration());
	}

	/**
	 * Specifies whether to use field mapping or property mapping
	 * @param accessStrategy
	 */
	protected void setAccessStrategy(AccessStrategy accessStrategy) {
		mappingChecker.setAccessStrategy(accessStrategy);
	}

	/**
	 * Verify that the class is mapped to the specified table
	 * 
	 * @param type
	 * @param tableName
	 */
	protected void assertClassMapping(Class type, String tableName) {
		HibernateMappingChecker r = this.mappingChecker;
		classChecker = r.getClassChecker(type);
		classChecker.assertClassMapping(type, tableName);
	}

	/**
	 * Verify that all classes and their fields/properties are mapped
	 */
	protected void assertAllClassesMapped() {
		mappingChecker.assertAllClassesMapped();
	}

	/**
	 * Verify that all classes and properties/properties are mapped except the specified fields/properties
	 * @param unmappedProperties
	 */
	protected void assertAllClassesMapped(Set<String> unmappedProperties) {
		mappingChecker.assertAllClassesMapped(unmappedProperties);
	}

}
